package com.card.game.dn;

import java.util.Vector;

import com.card.common.MessageComm;
import com.card.game.BasePlayer;
import com.card.game.Card;
import com.card.game.Hand;
import com.card.message.JsonMessageCenter;
import com.card.user.User;
import com.xiaoao.net.json.message.JsonMessage;

public class NnPlayer extends BasePlayer{
	public transient NnInfo nnInfo;
	private transient Hand hand = new Hand();
	public transient int niuNum;//0-没牛 1-9牛  80-炸弹 90-五花牛 100-五小牛
	public transient boolean isQiang;
	
	public NnPlayer(User user) {
		super(user);
		this.nnInfo = new NnInfo(user.getPrimaryKey());
	}
	
	public void initCards(Vector<Card> cards) {
		this.hand.cards = cards;
	}
	
	public void sendHandMessage() {
		JsonMessage message = new JsonMessage(MessageComm.S2C_HandUpdate2Out);
		message.addProperty("hand", getShowCards());
		message.addProperty("niuNum", niuNum);
		JsonMessageCenter.getInstance().sendMessage(message, this);
	}
//	public Vector<Card> getTrueCards() {
//		return hand.cards;
//	}
	public Vector<Card> getShowCards() {
		return hand.cards;
	}
	
	public Card getLastCard() {
		return hand.cards.get(4);
	}
	
	public void replaceLastCard(Card card) {
		hand.cards.remove(4);
		hand.cards.add(card);
	}
	
	@Override
	public void endGame() {
		this.setState(UserState.None);
		this.hand.clear();
		this.niuNum = -1;
		this.nnInfo.clear();
		this.isQiang = false;
	}
	
	public void checkNiu() {
		this.niuNum = DzUtils.getNiuNum(hand.cards);
	}
	public void showCard() {
		this.nnInfo.setCards(hand.cards,niuNum);
	}
	
	public void addWinScore(int score) {
		this.nnInfo.winScore += score;
		addScore(score);
	}
}
